# Maintainer: Jonas Witschel <diabonas@archlinux.org>
pkgname=java-commons-lang
pkgver=3.13.0
pkgrel=1
_java=17
pkgdesc='A host of helper utilities for the java.lang API'
arch=('any')
url='https://commons.apache.org/proper/commons-lang/'
license=('APACHE')
depends=('java-runtime-headless')
makedepends=("java-environment=${_java}" 'maven')
source=("http://archive.apache.org/dist/commons/lang/source/commons-lang3-$pkgver-src.tar.gz"{,.asc}
		"skip-broken-locales.patch")
sha512sums=('6fca0ce86aea84458021360bac3f6775135a1a5c1826194921e2d4ead7c12f6ac560e7c3fc240112f862aaee24be8754c37dd867f45e9449cde4a388018d8691'
            'SKIP'
            '38d5f2ed62af26e0d456719d2a8a6de144deec00d1c1e9b2bb89fcc4579e16254d2c298b61be3b52f95bce6a6d512ba33f6108dd6ffa4795397def6ea59df5d8')
validpgpkeys=('B6E73D84EA4FCC47166087253FAAD2CD5ECBB314'  # Rob Tompkins <chtompki@apache.org>
              '2DB4F1EF0FA761ECC4EA935C86FDC7E2A11262CB') # Gary David Gregory (Code signing key) <ggregory@apache.org>

prepare() {
	cd "commons-lang3-$pkgver-src"
	patch -Np1 < '../skip-broken-locales.patch'
}

build() {
	cd "commons-lang3-$pkgver-src"

	# Building with JDK 17 currently leads to a test failure of
	# "ToStringBuilderTest"
	export PATH="/usr/lib/jvm/java-${_java}-openjdk/bin:$PATH"

	mvn -am \
		-Dproject.build.outputTimestamp="$SOURCE_DATE_EPOCH" \
		-Dmaven.javadoc.skip=true \
		-Dmaven.test.skip=true \
		clean package
}

check() {
	cd "commons-lang3-$pkgver-src"
	export PATH="/usr/lib/jvm/java-${_java}-openjdk/bin:$PATH"
	mvn test
}

package() {
	cd "commons-lang3-$pkgver-src"
	install -Dm644 "target/commons-lang3-$pkgver.jar" -t "$pkgdir/usr/share/java/commons-lang"
	ln -s "commons-lang3-$pkgver.jar" "$pkgdir/usr/share/java/commons-lang/commons-lang.jar"
}
